home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.orig.lzh / nntpdiffs / src / ihave.c next >
C/C++ Source or Header  |  1989-06-27  |  1KB  |  73 lines

  1. #ifndef lint
  2. static char    *sccsid = "@(#)ihave.c    1.11    (Berkeley) 1/11/88";
  3. #endif
  4.  
  5. #include "common.h"
  6.  
  7. #ifdef LOG
  8. int    ih_accepted;
  9. int    ih_rejected;
  10. int    ih_failed;
  11. #endif LOG
  12.  
  13. /*
  14.  * IHAVE <messageid>
  15.  *
  16.  * Accept an article for transferral if we haven't seen it before.
  17.  */
  18.  
  19. ihave(argc, argv)
  20.     int        argc;
  21.     char        *argv[];
  22. {
  23.     char        errbuf[2 * NNTP_STRLEN];
  24.     int        retcode;
  25.     register char    *cp;
  26.  
  27.     if (argc != 2) {
  28.         printf("%d Usage: IHAVE <message-id>.\r\n", ERR_CMDSYN);
  29.         (void) fflush(stdout);
  30.         return;
  31.     }
  32.  
  33.     cp = gethistent(argv[1]);
  34.     if (cp != NULL) {
  35.         printf("%d Got it.\r\n", ERR_GOTIT);
  36.         (void) fflush(stdout);
  37. #ifdef LOG
  38.         ih_rejected++;
  39. #ifdef IHAVE_DEBUG
  40.         syslog(LOG_DEBUG, "%s ihave %s rejected", hostname, argv[1]);
  41. #endif IHAVE_DEBUG
  42. #endif LOG
  43.         return;
  44.     }
  45.         
  46. #ifdef UNBATCHED_INPUT
  47.     retcode = spawn(rnews, "rnews", (char *) 0, CONT_XFER,
  48.         ERR_XFERFAIL, errbuf);
  49. #else
  50.     /* C news input hook */
  51.     retcode = batch_input_article(CONT_XFER, ERR_XFERFAIL, errbuf);
  52. #endif
  53.     if (retcode <= 0)
  54.         printf("%d %s\r\n", ERR_XFERFAIL, errbuf);
  55.     else if (retcode > 0)
  56.         printf("%d Thanks.\r\n",
  57.             OK_XFERED);
  58.     (void) fflush(stdout);
  59.  
  60. #ifdef LOG
  61.     if (retcode == 1)
  62.         ih_accepted++;
  63.     else
  64.         ih_failed++;
  65.         
  66. #ifdef IHAVE_DEBUG
  67.     syslog(LOG_DEBUG, "%s ihave %s accepted %s",
  68.         hostname, argv[1], retcode == 1 ? "succeeded" : "failed");
  69. #endif IHAVE_DEBUG
  70. #endif LOG
  71.  
  72. }
  73.